Emit FS0755 for CompiledName on multi-value let-bindings#19924
Conversation
…#6131) Tests assert FS0755 is emitted at type-check time when [<CompiledName>] is applied to a tuple/record/wildcard destructuring binding. These FAIL on current main; sprint 02 will make them GREEN. Baseline on main: 6 failed (the FS0755 tests), 4 succeeded (the still-compiles tests). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6131) [<CompiledName(`X`)>] let a, b = 1, 2 silently propagated the same compiled name to every value introduced by the destructuring pattern, crashing later with FS0192 / FS2014 (duplicate IL entries) during IL writing. Detect destructuring patterns in TcNormalizedBinding (tuple/record/list/cons/or/ands/wild etc) and emit the existing FS0755 (tcCompiledNameAttributeMisused) diagnostic once, at the binding pattern range, during type checking. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bindings (#6131) Adds 11.0.100 release-note entry. Pure docs/formatting follow-up to the type-checker fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6131) Replace the ~30-line syntactic SynPat walker (isSimpleValBindingPat) in TcNormalizedBinding with a single Map.count valSchemes > 1 check inside MakeAndPublishVals. The post-generalization val schemes are the authoritative count of values published by the binding, so the check is exact instead of approximate. This removes false positives the walker produced (single-field record destructure, single-element array, single-binding cons, let a, _ = ...) and closes a false negative on let (x as y) = 1, which previously slipped through the walker and ICE'd in IlxGen.MergeOptions during IL writing. Negative tests added for single-value destructures and active-pattern function bindings; the let (x as y) = 1 regression is added to the positive set. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
Warning No PR link found in some release notes, please consider adding it.
|
All 12 failing jobs on AzDO build 1456244 reported 'Unable to obtain an authenticated token for running job ... dnceng-public'. The 18 sibling jobs (Linux, MacOS, several Windows configs, CheckCodeFormatting) passed against the same commit, confirming the failures are infrastructure-only. Empty commit to force a new CI run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
T-Gro
left a comment
There was a problem hiding this comment.
Review: Looks good. The check placement in MakeAndPublishVals is the right spot — it's after generalization so Map.count valSchemes is authoritative for how many vals the binding actually publishes. Reusing FS0755 (tcCompiledNameAttributeMisused) is appropriate since the existing message text already covers this scenario.
Tests are thorough: covers tuples, nested tuples, record patterns, DU patterns, array/cons patterns, as patterns, verifies the error fires exactly once, and includes negative tests for single-val destructures and multi-case active patterns.
Minor nit (non-blocking): the range0 sentinel in the fold is a known idiom in the codebase but a one-liner match ... with [] -> range0 | ... might be marginally clearer. Not worth a revision.
CI green (50/50). LGTM.
Fixes #6131